﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Tetris
{
    public partial class Tetris : Form
    {
        public Tetris()
        {
            InitializeComponent();
            timer.Interval = 40;
            timer.Tick += new EventHandler(timer_Tick);
            this.KeyDown += new KeyEventHandler(Form1_KeyDown);
        }

        private void timer_Tick(object sender, EventArgs e)
        {
            if (this.Size.Height != pictureBox1.Location.Y-pictureBox1.Size.Height)
            {
            pictureBox1.Location = new Point(pictureBox1.Location.X, pictureBox1.Location.Y + 1);
            pictureBox2.Visible = false;
            }
            else{
            pictureBox2.Location = new Point(pictureBox2.Location.X, pictureBox2.Location.Y + 1);
            pictureBox2.Visible = true;
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (!timer.Enabled)
                timer.Start();
            else
            {
                timer.Stop();
            }
        }

        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyData == Keys.Q)
            {
                pictureBox1.Location = new Point(pictureBox1.Location.X-10, pictureBox1.Location.Y);
            }
            if (e.KeyData == Keys.D)
            {
                pictureBox1.Location = new Point(pictureBox1.Location.X + 10, pictureBox1.Location.Y);
            }
        }
    }
}
